<template>
    <div :class="real_them" @click="dynamic_detail" >
    <div class="title">{{ this.title }}</div>
     <div class="introduce">{{ this.introduce}}</div>
    
      <div class="left">
        <div class="author">作者：{{this.author}}</div>
        <div class="date">{{ date }}</div>
      </div>
    <div class="footer">
      <div class="tag">
          <TagVue
            v-for="(i, index) of tag"
            :key="index"
            :name="i[0]"
            :color="i[1]"
          />
          </div>
      <div class="right">
        <i class="el-icon-thumb"></i> <span>{{ real_like }}</span>
        <i class="el-icon-chat-dot-square"></i> <span>{{ real_comment }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import TagVue from "./Tag.vue";
export default {
  name: "Dynamic_detail",
  // 动态页的组件点击后手动push至新的详情页 -- dynamic_detailin
  components: { TagVue },
   props: {
    title: {
      // type: String,
      required: true,
    },
    introduce: {
      // type: String,
      required: true,
    },
    author: {
      // type: String,
      required: true,
    },
    like: {
      // type: Number,
      default: 0,
    },
    comment: {
      // type: Number,
      default: 0,
    },
    date:{
      // type: String,
      required: true,
    },
    tag: {
      // type: Array,
      default: () => {
        return [
          ["前端"],
          ["JS"],
          ["原创", "danger"],
        ];
      },
    },
    comments:{
      // type: Array,
      required: true,
    },
    id:{
      require:true
    },
    likeusers:{
      require:true
    },
    icon:{
      
    }
  },
  methods: {
    dynamic_detail() {
      this.$router.push({
        path:"/dynamic_detail",
        query:{ 
          id:this.id,
          title:this.title,
          tag: this.tag,   
          date:this.date,
          author: this.author, 
          introduce: this.introduce,
          like: this.like,
          comment:this.comment,
          comments:this.comments,
          likeusers:this.likeusers,
          icon:this.icon
          }
      })
    },
  },
  computed: {
    real_like() {
      if (this.like > 999) {
        return "999+";
      }
      return this.like;
    },
    real_comment() {
      if (this.comment > 999) {
        return "999+";
      }
      return this.comment;
    },
    real_them() {
      let k = this.$store.state.skin;
      let m = k == true ? "light" : "dark";
      return "outer" + " " + m;
    },
  },
};
</script>

<style lang="less" scoped>
@import "../main.less";

.light {
  transition: all 1s;
  .title {
    color: @fs_light_contain;
  }
  .introduce{
    color: @fs_light_contain;
  }
  .footer {
    color: @fs_light_smcontain;
  }
   .left {
    color: @fs_light_smcontain;
  }
  &:hover {
    background-color: @bg_light_blue;
  }
}
.dark {
  transition: all 1s;
  .title {
    color: @fs_dark_contain;
  }
  .introduce {
    color: @fs_dark_contain;
  }
  .footer {
    color: @fs_dark_smcontain;
  }
  .left {
    color: @fs_dark_smcontain;
  }
  &:hover {
    background-color: @bg_dark_blue;
  }
}
.outer {
  width: 48%;
  height: 25%;
  
  cursor: pointer;
  .title {
    height: 30%;
    padding: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .introduce{
    font-size: 14px;
    height: 24%;
    margin-left: 10px;
    margin-right:10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .left {
     height: 20%;
      padding: 10px;
      display: flex;
      align-items: center;
      font-size: 14px;
      justify-content: space-between;

      .date{
        margin-right: 10%;
      }
    }  
  .footer {
    padding: 0 10px;
    height: 25%;
    display: flex;
    justify-content: space-between;
    align-items: center;
      .tag {
        display: flex;
        align-items: center;
      }
    
    .right {
      text-align: right;
      width: 40%;
      span {
        font-size: 14px;
        margin-right: 10px;
      }
    }
  }
  &:hover {
    transition: all 1s;
  }
}
</style>